<template>
  <el-form ref="form" :model="form" :inline="true" label-width="160px">
    <el-form-item style="width: 300px" label="课题名称：" prop="topicName">
      {{ form.topicName }}
    </el-form-item>
    <el-form-item label="课题编号：" prop="projectNumber">
      {{ form.projectNumber }}
    </el-form-item>
    <el-form-item style="width: 300px" label="课题负责人：" prop="speaker">
      {{ form.speaker }}
    </el-form-item>
    <el-form-item label="开课单位：" prop="organizingUnit">
      {{ form.speaker }}
    </el-form-item>
    <el-form-item style="width: 300px" label="开课时间：" prop="startTime">
      {{ form.startTime }}
    </el-form-item>
    <el-form-item label="结束时间：" prop="endTime">
      {{ form.startTime }}
    </el-form-item>
    <el-form-item style="width: 300px" label="课题成员：" prop="projectMember">
      {{ form.projectMember }}
    </el-form-item>

    <el-form-item label="课题领域：" prop="projectDomain">
      {{ form.projectDomain }}
    </el-form-item>
    <el-form-item style="width: 300px" label="资金预算：" prop="capitalBudget">
      {{ form.capitalBudget }}
    </el-form-item>
    <el-form-item label="资金来源：" prop="capitalSource">
      {{ form.capitalSource }}
    </el-form-item>
    <el-form-item style="width: 700px" label="课题状态：" prop="projectState">
      <dict-tag :options="dict.type.viillage_project_state" :value="form.projectState"/>
    </el-form-item>
    <el-form-item style="width: 100%" label="课题简介：" prop="introduction">
      <div style="width: 500px;">
        {{ form.introduction }}
      </div>
    </el-form-item>
    <el-form-item label="资料上传列表：" prop="cutOffTime">
      <el-button type="primary" @click="dataopen = true">上传资料</el-button>
    </el-form-item>
    <el-dialog title="资料上传" :visible.sync="dataopen" width="900px" append-to-body>

      <el-form-item style="width: 600px" label="申报书：" prop="declaration">
        <file-upload style="margin-left: 240px;" :openUplad="false" :isShowTip="false" v-model="form.declaration"/>
      </el-form-item>
      <el-form-item style="width: 600px" label="任务书：" prop="assignmentBook">
        <file-upload style="margin-left: 240px;" :openUplad="false" :isShowTip="false"
                     v-model="form.assignmentBook"
        />
      </el-form-item>
      <el-form-item style="width: 600px" label="开题报告：" prop="thesisProposal">
        <file-upload style="margin-left: 240px;" :openUplad="false" :isShowTip="false"
                     v-model="form.thesisProposal"
        />
      </el-form-item>
      <el-form-item style="width: 600px" label="中期报告：" prop="interimReport">
        <file-upload style="margin-left: 240px;" :openUplad="false" :isShowTip="false" v-model="form.interimReport"/>
      </el-form-item>
      <el-form-item style="width: 600px" label="结题材料：" prop="concludingMaterial">
        <file-upload style="margin-left: 240px;" :openUplad="false" :isShowTip="false"
                     v-model="form.concludingMaterial"
        />
      </el-form-item>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dataopen = false">确 定</el-button>
      </div>
    </el-dialog>

    <el-form-item style="width: 100%" label="备注：" prop="subjectSummary">
      <div style="width: 500px;">
        {{ form.subjectSummary }}
      </div>
    </el-form-item>
  </el-form>
</template>

<script>
import { getTopics } from '@/api/village/topics'

export default {
  name: 'Topics',
  dicts: ['viillage_project_state'],
  data() {
    return {
      start: 1,
      dataopen: false,
      detailopen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 横向课题管理表格数据
      topicsList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectNumber: null,
        topicName: null,
        projectState: null
      },
      // 表单参数
      form: {
        projectState: 1
      },

    }
  },
  created() {
    this.getList()
    console.log(this.$route.query.id)
  },
  methods: {
    skipDetail(row) {
      this.reset()
      const id = row.id || this.ids
      getTopics(id).then(response => {
        this.form = response.data
        this.detailopen = true
      })
    },
    /** 查询横向课题管理列表 */
    getList() {
      this.loading = true
      getTopics(this.$route.query.id).then(response => {
        console.log(response.data)
        this.form = response.data
      })
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        projectNumber: null,
        topicName: null,
        organizingUnit: null,
        startTime: null,
        endTime: null,
        speaker: null,
        projectMember: null,
        introduction: null,
        projectDomain: null,
        capitalBudget: null,
        capitalSource: null,
        projectAccessory: null,
        projectState: null,
        subjectSummary: null,
        participants: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null,
        isDelete: null
      }
      this.resetForm('form')
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    }
  }
}
</script>
